package com.zhm.demo.controller.req;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@Data
public class EmqxHookPublicMsgReq {

    public static final String EVENT="message.publish";

    /*
    {"username":"admin","topic":"/ext/ntp/k0ekpKNA55m/330022320240308/request","timestamp":1712658013935,"qos":0,"publish_received_at":1712658013935,"pub_props":{"User-Property":{}},"peerhost":"10.101.0.232","payload":"{\"deviceSendTime\":\"765973209604\"}","node":"emqx@127.0.0.1","metadata":{"rule_id":"test-wh_WH_D"},"id":"000615A7448AD87FF445000025E40008","flags":{"retain":false,"dup":false},"event":"message.publish","clientid":"330022320240308"}
     */

    @JsonProperty("username")
    private String username;
    @JsonProperty("topic")
    private String topic;
    @JsonProperty("timestamp")
    private Long timestamp;
    @JsonProperty("qos")
    private Integer qos;
    @JsonProperty("publish_received_at")
    private Long publishReceivedAt;
    @JsonProperty("pub_props")
    private PubPropsDTO pubProps;
    @JsonProperty("peerhost")
    private String peerhost;
    @JsonProperty("payload")
    private String payload;
    @JsonProperty("node")
    private String node;
    @JsonProperty("metadata")
    private MetadataDTO metadata;
    @JsonProperty("id")
    private String id;
    @JsonProperty("flags")
    private FlagsDTO flags;
    @JsonProperty("event")
    private String event;
    @JsonProperty("clientid")
    private String clientid;

    @NoArgsConstructor
    @Data
    public static class PubPropsDTO {
        @JsonProperty("User-Property")
        private UserPropertyDTO userProperty;

        @NoArgsConstructor
        @Data
        public static class UserPropertyDTO {
        }
    }

    @NoArgsConstructor
    @Data
    public static class MetadataDTO {
        @JsonProperty("rule_id")
        private String ruleId;
    }

    @NoArgsConstructor
    @Data
    public static class FlagsDTO {
        @JsonProperty("retain")
        private Boolean retain;
        @JsonProperty("dup")
        private Boolean dup;
    }
}
